package com.shanyi.sendmsg.tool;

import org.springframework.stereotype.Service;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;

@Service
public class SetClipboard {
    public static void SetClipboard(String text) {
        // 获取系统剪贴板
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        // 封装文本内容
        StringSelection selection = new StringSelection(text);
        // 把文本内容设置到系统剪贴板
        clipboard.setContents(selection,null);
    }
}
